package per.sunmes.cl.g.sys;

import java.util.Random;

public class RandU {

	private static Random rand = new Random(System.currentTimeMillis());

	/**
	 * @param min
	 * @param max
	 * @return [min,max)
	 */
	public static int rand(int min, int max) {
		if (min > max) {
			int tmp = max;
			max = min;
			min = tmp;
		} else if (min == max) {
			return min;
		}
		return min + (int) (rand.nextFloat() * (max - min));
	}

	/**
	 * @param min
	 * @param max
	 * @return [min,max)
	 */
	public static float rand(float min, float max) {
		if (min > max) {
			float tmp = max;
			max = min;
			min = tmp;
		} else if (min == max) {
			return min;
		}

		return min + rand.nextFloat() * (max - min);
	}

}
